//
//  SecondViewController.m
//  block的使用总结
//
//  Created by 唐斌 on 2018/2/5.
//  Copyright © 2018年 唐斌科技有限公司. All rights reserved.
//

#import "SecondViewController.h"
#import "TestTableViewCell.h"

@interface SecondViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation SecondViewController

static NSString* const BtMeCellId = @"BtMeCellId";

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    // 先注册从缓存池中取出的cell, XMGTopicCell是用xib自定义的cell的名称,
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([TestTableViewCell class]) bundle:nil] forCellReuseIdentifier:BtMeCellId];
    
}


- (IBAction)backToHomeVCBtnClicked:(id)sender {
    _passValueBlock1(@"这是控制器2返回的值");
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TestTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:BtMeCellId];
    
    if (nil == cell) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"TestTableViewCell" owner:nil options:nil] firstObject];
    }
    cell.myblock = ^(NSString *blockStr) {
        _titleLabel.text = blockStr;
    };
    
    return cell;
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
